package cn.tedu._05mvcboot01.controller;


import cn.tedu._05mvcboot01.pojo.dto.UserLoginDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {
    @RequestMapping("/v1/users/login")
    @ResponseBody
    public String login() {
        return "login";
    }

    @RequestMapping("/v1/users/register")
    @ResponseBody
    public String register() {
        return "register";
    }

    @RequestMapping("/v1/users/login1")
    @ResponseBody
    public String login1(HttpServletRequest request) {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        return "第1方法:" + username + ":" + password;
    }

    @RequestMapping("/v1/users/login2")
    @ResponseBody
    public String login2(String username, String password) {
        return "第2方法:" + username + ":" + password;
    }

    @RequestMapping("/v1/users/login3")
    @ResponseBody
    public String login3(UserLoginDTO userLoginDTO) {
        return "第3方法:" + userLoginDTO.getUsername() + ":" + userLoginDTO.getPassword();
    }
}
